attribute vec4 position;
attribute vec3 normal;
attribute vec3 diffuseMaterial;

uniform mat4 projection;
uniform mat4 modelview;
uniform mat3 normalMatrix;
uniform vec4 lightPosition;
uniform vec4 ambientMaterial;
uniform vec4 specularMaterial;
uniform float shininess;

varying vec4 dstColor;

void main(void)
{
vec3 n = normalMatrix * normal;
vec3 l = normalize(lightPosition);
vec4 e = vec3(0, 0, 1);
vec3 h = normalize(l + e);

float df = max(0.0, dot(n,l));
float sf = max(0.0, dot(n,h));
sf = pow(sf, shininess);

vec3 color = ambientMaterial + df * diffuseMaterial + sf * specularMaterial;

dstColor = vec4(color, 1);
gl_Position = projection * modelview * position;
}